#ifndef BASE_TCP_SERVER_HPP
#define BASE_TCP_SERVER_HPP

#include <base/defines.h>
#include <base/log.h>
#include <mutex>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <cstring>

#define BACKLOG 5

class TcpServer {
    public:
        static TcpServer* GetInstance(int port); 
        int GetListenSock();
        ~TcpServer();
        NONCOPYABLE(TcpServer);
        IMMOVEABLE(TcpServer);

    private:
        TcpServer(int port);
        void InitTcpServer();
        void Sock();
        void Bind();
        void Listen();
    private:
        int listen_sock_;
        int port_;
        static TcpServer* instance_;
        static std::mutex mutex_;
};


#endif